<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>注册用户</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<!-- CSS -->
	<link href="style/css/transdmin.css" rel="stylesheet" type="text/css" media="screen" />
	<link rel="stylesheet" type="text/css" media="screen" href="style/css/ie6.css" />
	<link rel="stylesheet" type="text/css" media="screen" href="style/css/ie7.css" />

	<!-- JavaScripts-->
	<script type="text/javascript" src="style/js/json2.js"></script>
	<script type="text/javascript" src="style/js/jquery-1.8.2.min.js"></script>
	<script type="text/javascript" src="style/js/jNice.js"></script>	
  	<script type="text/javascript">	
 	function newUser()
 	{
 		var userName = $("input#userName").val().trim() ;
 		var password = $("input#password").val().trim();
 		var password_confirm = $("input#password_confirm").val().trim();
 		var valid_code = $("input#validCodeAnswer").val().trim();
 		var qq = $("input#qq").val().trim() ;
 		var email = $("input#email").val().trim() ;
 		if (userName == '' || password =='' || password_confirm == '' 
 			|| valid_code == '' || qq == '' || email == '')
 		{
 			alert('所有输入项不能为空');
 			return;
 		}
 		if (userName.replace(/[0-9a-zA-Z]{6,20}/g,'') != '' ||
 			password.replace(/[0-9a-zA-Z]{6,20}/g,'') != '')
 		{
 			alert('无效的用户名密码');
 			return ;
 		}
 		if (password != password_confirm)
 		{
 			alert('二次输入的密码不匹配');
 			return ;
 		}
		$.ajax({
			url: 'user',
			type: "get",
			data: {
		        'actionType' : 'createUser',
		        'userName' : userName,
		        'password': password,
		        'validCodeAnswer': valid_code,
		        'qq':qq,
		        'email':email
		    },
			success: function(transport) {
				var result = transport.responseText;
				if (result == '0')
				{
					alert('注册成功,请登陆');
					relogin();
				}
				else
				{
					alert(result);
					show(document.getElementById('validImg'));
				}
	  		}
		});
	}
	function show(o) {
	  // 重新载入验证码
	  var timenow = new Date().getTime();
	  o.src = "validatecode?d=" + timenow;
	 }
  	</script>
  </head>
  <body>
	<form action="user" method="GET" name="loginForm" id="loginForm">
      	<input type=hidden id=actionType name=actionType value=login></input>
       	<h3>注册</h3>
      	<fieldset>
      		<p>用户名(数字、字母、下划线组成的6-20位的字符串):</p><p><input type="text" name="userName" id="userName" class="text-medium" maxlength=20/></input></p>
      		<p>密码(数字、字母、下划线组成的6-20位的字符串):</p><p><input type="password" name="password" id="password" class="text-medium" maxlength=20/></input></p>
      		<p>确认密码:</p><p><input type="password" name="password_confirm" id="password_confirm" class="text-medium" maxlength=20/></input></p>
			<p>QQ(用于技术支持):</p><p><input type="text" name="qq" id="qq" class="text-medium" maxlength=12/></input></p>
			<p>email(用于通知服务):</p><p><input type="text" name="email" id="email" class="text-medium" maxlength=32/></input></p>            
            <p>验证码:</p><p><input type="text" name="validCodeAnswer" class="text-small" id="validCodeAnswer" value='' maxlength=4></input><img src="validatecode" name="validImg" id="validImg"/><a href="javascript:show(document.getElementById('validImg'))">看不清?</a></p>
            <p><input type="submit" name="submit" id="submit" value="注册" onClick="return false;"/></p>
      	</fieldset>
    </form>
  </body>
</html>
